<extend name="common:commonSimpleNewTemplate" />
<block name="main_content">
<style type="text/css">
	.input_check_box {opacity: 1!important;}
</style>
<div>
	<div class="container-fluid" id="biz_dealer">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>搜索条件</h5>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate" id="basic_validate"
							name="basic_validate" action="#" method="post"
							class="form-horizontal">
							
							<div class="control-group">
								<label class="control-label" style="width: 90px;">标签:</label>
								<div class="controls" style="margin-left: 120px;">
									<select id="tag_name" name="tag_name">
										<foreach name="lst_tag" item="obj" key="key" >
											<option value="{$obj.tagid}">{$obj.tagname}</option>
										</foreach >
									</select>
								</div>
							</div>
							
							<div class="control-group">
								<input id="btn_member_search" type="button" class="btn btn-success" value="搜索">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	
		<div class="row-fluid">
			<div class="span12">
				
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>可参加员工信息</h5>
					</div>
					<div class="widget-content nopadding" >
         				 <div class="widget-content nopadding">
           					 <table id="search_result" page_index="1" class="table table-bordered table-striped">
           					 	<thead>
	            					<tr>
	            					  <th width="20px">选择</th>
	             					  <th>员工编码</th>
	              					  <th>姓名</th>
	                                </tr>
                                </thead>
                                <tbody>
		                			<!-- <if condition="empty($lst_member_info)">
										<td colspan="3">暂时没有数据</td>
									<else /> 
										<volist name="lst_member_info" id="member_info" empty="暂时没有数据">
											<tr>
											    <td style='text-align: center;'><input class='input_check_box' name="checkBox" checked="checked"  user_id='{$member_info.userid}' user_name='{$member_info.name}' type='checkbox'></td>
												<td>{$member_info.userid}</td>
												<td>{$member_info.name}</td>
											</tr>
										</volist> 
									</if> -->
                            	</tbody>
                            </table>
                    	</div>
					</div>
					<div class="control-group">
                  		<button id='check_this_member' class="btn btn-success" type="submit">添加</button>
               		</div>
				</div>
			</div>
		</div>
	</div>
</div>
</block>

<block name="js_content">
<script>

MemeberSearchPage = {
	'BindEvent': function(){
		$('#check_this_member').bind('click',function(){
			var members = [];
			$('input[name="checkBox"]:checked').each(function(index,obj){
				members.push({user_id:$(obj).attr('user_id'),name:$(obj).attr('user_name')});
			}); 
			
			if(members.length == 0){
				alert('请至少选择一个员工!');
				return;
			}
			parent.MeetingPage.addTmpTag(members);
			var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
		    parent.layer.close(index); //执行关闭
			
		});
		$('#btn_member_search').bind('click',function(){
			MemeberSearchPage.Search();
		});
	},
	'Search': function () {
		var param = {};
    	param.tag_id = $('#tag_name').val();
    	param.meeting_id = "{$meeting_id}";
    	param.access_token = "{$access_token}";
        $.ajax({
            type: 'post',
            url: '/AjaxService/center/meeting/gettagmember',
            data: param,
            dataType: 'json',
            success: function (data) {
            	if(data.IsSuccess == 0){
            		alert(data.ErrorMsg);
            	}else{
	            	MemeberSearchPage.BindTable(data.Result);
            	}
            },
            error: function (e, err_name, err_text) {
                alert(err_text);
            }
        });

    },
	'BindTable': function(lst_remeber){
		if(lst_remeber.length == 0){	
			$('#search_result tbody').html('');
			var msg ="<tr><td colspan='16' style='text-align:center'>暂无数据!</td></tr>";				
			$('#search_result tbody').append(msg);	
			return;
		};
		var html = '';
		for(var index in lst_remeber){
			var remember_en = lst_remeber[index];
			var tr_html = "<tr>";
			tr_html += "<td style='text-align: center;'> <input class='input_check_box' name='checkBox' checked='checked'  user_id='"+remember_en.userid+"' user_name='"+remember_en.name+"' type='checkbox'></td>";
			tr_html += "<td>" + remember_en.userid + "</td>";
			tr_html += "<td>" + remember_en.name + "</td>";
			tr_html += "</tr>";
			html += tr_html;
		} 
		$('#search_result tbody').html('');
		$('#search_result tbody').append(html);
	},
};


$(document).ready(function(){
	var errorMsg = "{$error_msg}";
	if(errorMsg && errorMsg != ''){
		alert(errorMsg);
	}
	MemeberSearchPage.BindEvent();
});

</script>
</block>